﻿workspace "Hazal"
	architecture "x64"

	configurations
	{
		"Debug",
		"Release",
		"Dist",
	}

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"

IncludeDir = {} -- 项目字典
IncludeDir["GLFW"]  = "InLib/glfw/include"
IncludeDir["GLAD"]  = "InLib/glad/include"
IncludeDir["ImGui"] = "InLib/imgui"		  
IncludeDir["ImGuizmo"] = "InLib/ImGuizmo"		  
IncludeDir["GLM"] = "InLib/glm"			  
IncludeDir["stb_image"] = "Hazal/SourceCode/Base/stb_image"
IncludeDir["entt"] = "InLib/entt/include"
IncludeDir["yaml"] = "InLib/yaml-cpp/include"
IncludeDir["SPIRV_Cross"] = "InLib/SPIRV-Cross"
IncludeDir["Box2D"] = "InLib/box2d/include"


-- 查找并执行另一个脚本文件
include "InLib/glfw"			-- GLFW
include "InLib/glad"			-- GLAD
include "InLib/imgui"			-- ImGui
include "InLib/yaml-cpp"		-- yaml
include "InLib/SPIRV-Cross"		-- SPIRV_Cross
include "InLib/box2d"			-- box2d

project "Hazal"
	location "Hazal"			-- 项目生成位置(如Hazal.vcxproj)
	kind "StaticLib"			-- 项目输出类型为静态库
	language "C++"
	cppdialect "C++20"
	staticruntime "on"

	targetdir ("Product/Hazal")	-- dll输出目录
	objdir ("Bin/Hazal")		-- bin文件输出目录

	-- shell commands
	buildoptions
	{
		"/utf-8",
	}

	-- 预编译头
	pchheader "hzpch.h"
	pchsource "%{prj.name}/SourceCode/Base/hzpch.cpp" -- 预编译cpp的真实路径

	files
	{
		"%{prj.name}/**.h",
		"%{prj.name}/**.hpp",
		"%{prj.name}/**.cpp",

		"InLib/ImGuizmo/ImGuizmo.h",
		"InLib/ImGuizmo/ImGuizmo.cpp",
	}

	defines
	{
		"_CRT_SECURE_NO_WARNINGS",
		"YAML_CPP_STATIC_DEFINE",
	}

	-- 包含附加目录
	includedirs
	{
		"InLib/spdlog/include",
		"%{prj.name}/",
		"%{prj.name}/SourceCode",
		"%{prj.name}/SourceCode/Base",
		"%{IncludeDir.GLFW}",
		"%{IncludeDir.GLAD}",
		"%{IncludeDir.ImGui}",
		"%{IncludeDir.ImGuizmo}",
		"%{IncludeDir.GLM}",
		"%{IncludeDir.stb_image}",
		"%{IncludeDir.entt}",
		"%{IncludeDir.yaml}",
		"%{IncludeDir.SPIRV_Cross}",
		"%{IncludeDir.Box2D}",
	}

	libdirs 
	{
		"%{prj.name}/../InLib/shaderc/lib/Debug",	--cmake生成的工程, 直接使用编译好的库
	}

	links
	{
		"yaml",
		"GLFW",			--相同项目的库
		"GLAD",
		"ImGui",
		"SPIRV_Cross",
		"opengl32.lib",	--系统库
		"shaderc_shared.lib",
		"Box2D",
	}

	-- ImGuizmo文件不要预编译头
	filter "files:InLib/ImGuizmo/**.cpp"
	flags {"NoPCH"}

	filter "files:SourceCode/Shaderc/shaderc.hpp"
	flags {"NoPCH"}

	filter "system:windows"
		systemversion "latest"

		defines
		{
			"_CONSOLE",
			"DEF_DLL_EXPORT",
			"DEF_PLATFORM_WINDOWS",
			"DEF_ENABLE_ASSERTS",
			"GLFW_INCLUDE_NONE",
			"SHADERC_SHAREDLIB",
		}

		-- 生成后事件, 将dll文件拷贝到指定目录下(静态库不需要)
		postbuildcommands
		{
			("{COPY} ../InLib/shaderc/lib/Debug/shaderc_shared.dll " .. "../Product/SandBox/")
		}

	filter "configurations:Debug"
		defines "_DEBUG"
		buildoptions "/MDd"
		symbols "on"

	filter "configurations:Release"
		defines "_RELEASE"
		buildoptions "/MD"
		optimize "on"

	filter "configurations:Dist"
		defines "_DIST"
		buildoptions "/MD"
		optimize "on"

project "SandBox"
	location "SandBox"
	kind "ConsoleApp"
	language "C++"
	cppdialect "C++20"

	targetdir ("Product/SandBox")
	objdir ("Bin/SandBox")

	-- 调试目录
	debugdir "Product/SandBox"

	files
	{
		"%{prj.name}/**.h",
		"%{prj.name}/**.cpp",
	}

	includedirs
	{
		"./",
		"InLib/spdlog/include",
		"Hazal",
		"%{IncludeDir.GLM}",
		"%{IncludeDir.ImGui}",
		"%{IncludeDir.ImGuizmo}",
		"%{IncludeDir.entt}",
		"%{IncludeDir.yaml}",
		"%{IncludeDir.Box2D}",
	}

	libdirs 
	{
		"%{prj.name}/../InLib/shaderc/lib/Debug",	--cmake生成的工程, 直接使用编译好的库
	}

	links
	{
		"Hazal",
		"shaderc_shared.lib",
	}

	-- shell commands
	buildoptions
	{
		"/utf-8",
	}

	filter "system:windows"
		staticruntime "on"
		systemversion "latest"

		defines
		{
			"_CONSOLE",
			"DEF_PLATFORM_WINDOWS",
			"YAML_CPP_STATIC_DEFINE",
		}

	filter "configurations:Debug"
		defines "_DEBUG"
		buildoptions "/MDd"
		symbols "on"

	filter "configurations:Release"
		defines "_RELEASE"
		buildoptions "/MD"
		optimize "on"

	filter "configurations:Dist"
		defines "_DIST"
		buildoptions "/MD"
		optimize "on"